<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<!DOCTYPE html>
<html>
<head>
</head>
<title>还款计划</title>
<style type="text/css">
    .layui-form-select dl {
        max-height: 150px;
    / / 原值为300，调节高度建议为50的倍数
    }

    .layui-form-label {
        width: 130px;
    }

    .layui-form-item {
        margin-bottom: 0px;
        clear: both;
        *zoom: 1;
    }
</style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- 查询区域  -->
        <div id="payInterest-query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">项目编码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="proCode" placeholder="请输入项目编码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">项目名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="proName" placeholder="请输入项目名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">区域公司</label>
                    <div class="layui-input-inline">
                        <select name="orgId">
                            <option value="">全部</option>
                            <c:if test="${not empty orgInfoList }">
                                <c:forEach items="${orgInfoList}" var="orgInfo">
                                    <option value="${orgInfo.id}">${orgInfo.compName }</option>
                                </c:forEach>
                            </c:if>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <select name="paymentStatus">
                            <option value="">全部</option>
                            <option value="0">未付款</option>
                            <option value="1">已付款</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="payInt-laydate-dates" name="dates" readonly
                               placeholder="请选择创建时间">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">合同融资总额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="beginSumCapAmt">
                    </div>
                    <div class="layui-form-mid">
                        -
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="endSumCapAmt">
                    </div>
                </div>
                <shiro:hasPermission name="LIST_PAYINTEREST">
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-payInterest-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit
                                lay-filter="lay-payInterest-back-reset">
                            <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                        </button>
                    </div>
                </shiro:hasPermission>
            </div>
        </div>
        <!-- 按钮区域  -->
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <shiro:hasPermission name="ADD_CONTRACTINFO">
                    <button class="layui-btn layuiadmin-btn-admin " data-type="add">
                        <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新建
                    </button>
                </shiro:hasPermission>
                <shiro:hasPermission name="EXPORT_CONTRACTINFO">
                    <button class="layui-btn layuiadmin-btn-admin " data-type="export" onclick="exportList();">
                        <i class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出
                    </button>
                </shiro:hasPermission>
            </div>
            <!-- 数据表单 -->
            <div class="layui-tab-item layui-show">
                <table id="lay-payInterest-create-manage" lay-filter="lay-payInterest-create-manage"></table>
            </div>
        </div>
    </div>
</div>

<script>
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'set', 'transfer', 'laydate', 'element', 'layer'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , element = layui.element
            , laydate = layui.laydate
            , layer = layui.layer;

        //日期
        laydate.render({
            elem: '#payInt-laydate-dates'
            , range: '~'
        });

        // 表单
        table.render({
            elem: '#lay-payInterest-create-manage'
            , url: basePath + '/repaymentSchedule/queryDataByCondition'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'proCode', title: '项目编码', width: 145}
                , {field: 'proName', title: '项目名称', width: 145}
                , {field: 'cityName', title: '项目城市', width: 155}
                , {
                    field: 'addTime', title: '创建时间', width: 160, templet: function (d) {
                        if (d.addTime != null) {
                            return layui.util.toDateString(d.addTime, "yyyy-MM-dd");
                        } else {
                            return '暂无时间';
                        }
                    }
                }
                , {field: 'sumAmt', title: '合同融资总额', width: 145}
                , {field: 'summoney', title: '还款总金额', width: 100}
                , {field: 'status', title: '付款状态', width: 100}
                , {
                    field: 'processStatus', title: '单据状态', width: 150, templet: function (d) {
                        if (d.processStatus == '1') {
                            return '审批中';
                        } else if (d.processStatus == '9') {
                            return '审批完成';
                        } else if (d.processStatus == '10') {
                            return '审批终止';
                        } else {
                            return ''
                        }
                    }
                }
                , {
                    title: '操作', width: 140, align: 'center', fixed: 'right', templet: function (d) {
                        var optStr = "";
                        optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                        return optStr;
                    }
                }
            ]]
            , page: true
            , limit: 10
        });

        //监听搜索
        form.on('submit(lay-payInterest-search)', function (data) {
            table.reload('lay-payInterest-create-manage', {
                page: {curr: 1},
                where: trimData(data)
            });
        });
        //重置清空
        form.on('submit(lay-payInterest-back-reset)', function (data) {
            reset_form('payInterest-query-form');
            //额外处理select
            $("#query-form-state").val('');
            form.render();
        });

        // 监听操作列
        table.on('tool(lay-payInterest-create-manage)', function (obj) {
            var data = obj.data;
            if (obj.event === 'view') {//查看详情
                parent.layui.index.openTabsPage(basePath + '/repaymentSchedule/toDealOrDetail?id=' + data.id + '&proCode=' + data.proCode, '还款计划 > 详情');
            }
        });

        var active = {
            add: function(){
                parent.layui.index.openTabsPage(basePath + '/repaymentSchedule/toDealOrDetail','还款计划 > 新建');
            }
        }

        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    //导出excel
    function exportList() {
        layer.msg("暂未上线，敬请期待~", {icon: 1});
        /*var $ = layui.$;
        var params = "?proCode=";
        params += $('#queryProCode').val().trim();
        params += "&startDate=";
        params += $('#sent-laydate-start').val().trim();
        params += "&endDate=";
        params += $('#sent-laydate-end').val().trim();
        params += "&customerName=";
        params += $('#queryCustomerName').val().trim();
        params += "&mobile=";
        params += $('#queryMobile').val().trim();
        params += "&provinceName=";
        params += $('#queryProvinceName').val().trim();
        params += "&cityName=";
        params += $('#queryCityName').val().trim();
        params += "&state=";
        params += $('#queryState').val().trim();
        window.location.href = "
        ${ctx}/preProject/exportToExcel"+params;*/
    }
</script>
</body>
</html>

